#!/usr/bin/python3
# -*- coding:UTF-8 -*-
'''Module DocString'''

__author__ = 'Wang Zhe'

from socket import *
import sys
reload(sys)
sys.setdefaultencoding('utf-8')


def tcp():
    """Function DocString"""
    port = 8081
    host = 'localhost'  # or "127.0.0.1"
    bufsize = 1024
    addr = (host, port)
    s = socket(AF_INET, SOCK_STREAM)
    s.connect(addr)

    while True:
        data = raw_input('> ')
        if not data:
            break
        s.send(data.decode("GBK").encode("utf-8"))
        data = s.recv(bufsize)
        if not data:
            break
        print(data.decode('utf-8'))
        print("1", data)
        print("1", data.decode("utf-8"))
    s.close()


def main():
    '''Func DocString'''
    tcp()
    pass


if __name__ == '__main__':
    main()
